Skip to main content

Git Init

Git Init

The first step to using Git in any project is to initialize a repository. This sets up a hidden .git directory that tracks your changes, branches, history, and more.

What is a Repository

A repository (or repo) is a directory where Git tracks and stores versions of your files. You can initialize a new Git repository in any folder using the git init command.

Once initialized, Git will start tracking changes in that folder — but only for files you tell it to track.

Create Your First Repository

  1. Open your terminal
  2. Navigate to a directory where you will keep your repo's
    • IF you don't have one I like to use projects: mkdir projects
cd  projects
  1. Initialize the repository:
git init git-demo
  1. You should see:
Initialized empty Git repository in /your/path/git-101/.git/
  1. Confirm Git is now tracking the folder:
ls -a  # or `dir /a` on Windows
tip

This command can be used on existing codebases or folders to track the chages of the files inside, not just new directories you create.

Enjoying the course? Found this useful? Check out the blog for more deep dives on data engineering and software.